package com.googlecode.npgame.simulation;

import android.graphics.Color;

/**
 * @author Josh (joshbruning)
 */
public class GLColor {

  private int color;
  private float red;
  private float green;
  private float blue;
  private float alpha;

  public GLColor(int color) {
    this.color = color;
    this.red = intColorToFloatColor(Color.red(color));
    this.green = intColorToFloatColor(Color.green(color));
    this.blue = intColorToFloatColor(Color.blue(color));
    this.alpha = intColorToFloatColor(Color.alpha(color));
  }

  public int getColor() {
    return color;
  }

  public float getRed() {
    return this.red;
  }

  public float getGreen() {
    return this.green;
  }

  public float getBlue() {
    return this.blue;
  }

  public float getAlpha() {
    return alpha;
  }

  private float intColorToFloatColor(int color) {
    if (color == 255) {
      return 1.0f;
    }

    return color / 255.0f;
  }
}
